﻿using System;
using Microsoft.EntityFrameworkCore.Migrations;

#nullable disable

namespace curriculum_design.Migrations
{
    /// <inheritdoc />
    public partial class init : Migration
    {
        /// <inheritdoc />
        protected override void Up(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.CreateTable(
                name: "Device",
                columns: table => new
                {
                    DeviceId = table.Column<int>(type: "int", nullable: false)
                        .Annotation("SqlServer:Identity", "1, 1"),
                    DeviceName = table.Column<string>(type: "nvarchar(max)", nullable: false),
                    Manufacturer = table.Column<string>(type: "nvarchar(max)", nullable: false),
                    Origin = table.Column<string>(type: "nvarchar(max)", nullable: false),
                    ProductionDate = table.Column<DateTime>(type: "datetime2", nullable: false),
                    InspectionDate = table.Column<DateTime>(type: "datetime2", nullable: false)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_Device", x => x.DeviceId);
                });

            migrationBuilder.CreateTable(
                name: "TestItem",
                columns: table => new
                {
                    ProjectId = table.Column<int>(type: "int", nullable: false)
                        .Annotation("SqlServer:Identity", "1, 1"),
                    ItemName = table.Column<string>(type: "nvarchar(max)", nullable: true),
                    Gear = table.Column<string>(type: "nvarchar(max)", nullable: true),
                    Percentage = table.Column<double>(type: "float", nullable: false),
                    LowerLimit = table.Column<double>(type: "float", nullable: false),
                    UpperLimit = table.Column<double>(type: "float", nullable: false),
                    RealData = table.Column<double>(type: "float", nullable: false),
                    DeviceId = table.Column<int>(type: "int", nullable: false)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_TestItem", x => x.ProjectId);
                    table.ForeignKey(
                        name: "FK_TestItem_Device_DeviceId",
                        column: x => x.DeviceId,
                        principalTable: "Device",
                        principalColumn: "DeviceId",
                        onDelete: ReferentialAction.Cascade);
                });

            migrationBuilder.CreateTable(
                name: "ResultClass",
                columns: table => new
                {
                    ResultId = table.Column<int>(type: "int", nullable: false)
                        .Annotation("SqlServer:Identity", "1, 1"),
                    sec_voltage = table.Column<double>(type: "float", nullable: false),
                    ao_f = table.Column<double>(type: "float", nullable: false),
                    bo_f = table.Column<double>(type: "float", nullable: false),
                    co_f = table.Column<double>(type: "float", nullable: false),
                    ao_d = table.Column<double>(type: "float", nullable: false),
                    bo_d = table.Column<double>(type: "float", nullable: false),
                    co_d = table.Column<double>(type: "float", nullable: false),
                    ao_du = table.Column<double>(type: "float", nullable: false),
                    bo_du = table.Column<double>(type: "float", nullable: false),
                    co_du = table.Column<double>(type: "float", nullable: false),
                    ao_Upt = table.Column<double>(type: "float", nullable: false),
                    bo_Upt = table.Column<double>(type: "float", nullable: false),
                    co_Upt = table.Column<double>(type: "float", nullable: false),
                    ao_Uyb = table.Column<double>(type: "float", nullable: false),
                    bo_Uyb = table.Column<double>(type: "float", nullable: false),
                    co_Uyb = table.Column<double>(type: "float", nullable: false),
                    r_persentage = table.Column<double>(type: "float", nullable: false),
                    TestId = table.Column<int>(type: "int", nullable: false)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_ResultClass", x => x.ResultId);
                    table.ForeignKey(
                        name: "FK_ResultClass_TestItem_TestId",
                        column: x => x.TestId,
                        principalTable: "TestItem",
                        principalColumn: "ProjectId",
                        onDelete: ReferentialAction.Cascade);
                });

            migrationBuilder.CreateIndex(
                name: "IX_ResultClass_TestId",
                table: "ResultClass",
                column: "TestId",
                unique: true);

            migrationBuilder.CreateIndex(
                name: "IX_TestItem_DeviceId",
                table: "TestItem",
                column: "DeviceId");
        }

        /// <inheritdoc />
        protected override void Down(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.DropTable(
                name: "ResultClass");

            migrationBuilder.DropTable(
                name: "TestItem");

            migrationBuilder.DropTable(
                name: "Device");
        }
    }
}
